<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Article;
use App\Repositories\ArticleRepo;
use Illuminate\Http\Request;
use App\Repositories\ArticleCategoryRepo;

class ArticleController extends BaseController
{
    //
    public function index(Request $request)
    {
         $articleRepo = new ArticleRepo();
         $data = $articleRepo->getPageList();
         return $this->sucRes(200,$data);
    }
    public function create(Request $request)
    {
        $data = $request->only(['title','sub_title','image','description','content','pid']);
        $articleRepo = new ArticleRepo();
        $articleRepo->create($data);
        return $this->sucRes();
    }
    public function update(Request $request)
    {
        $data = $request->only(['title','sub_title','description','image','content']);
        $id = $request->id;
        $articleRepo = new ArticleRepo();
        $articleRepo->update($id,$data);
        return $this->sucRes();
    }
    public function del(Request $request)
    {
        $id = $request->id;
        $articleRepo = new ArticleRepo();
        $articleRepo->del($id);
        return $this->sucRes();
    }
}
